using System;
using System.Collections.Generic;
using System.Text;

namespace BAFIRCSharp
{
    public class IRCQuery
    {
        // Information about channel
        public SenderInf Who;

        // Management stuff
        public List<ChatMessage> ChatBuffer;

        // Constructors
        public IRCQuery()
        {
            this.Who = new SenderInf();
            ChatBuffer = new List<ChatMessage>();
        }

        public IRCQuery(SenderInf Who)
        {
            this.Who = Who;
            ChatBuffer = new List<ChatMessage>();
        }

        public void NewPrivMsg(SenderInf Who, string Message)
        {
            ChatBuffer.Add(new ChatMessage(ChatMessage.ChatMessageType.PRIVMSG, DateTime.Now, Who, Message));
            Console.WriteLine("Query " + Who.Nickname + " " + DateTime.Now + " <" + Who.Nickname + "> " + Message);
        }

        public void NewNotice(SenderInf Who, string Message)
        {
            ChatBuffer.Add(new ChatMessage(ChatMessage.ChatMessageType.NOTICE, DateTime.Now, Who, Message));
            Console.WriteLine("Query " + Who.Nickname + " " + DateTime.Now + " -" + Who.Nickname + "- " + Message);
        }

        public void NewQuit(SenderInf Who, string Reason)
        {
            ChatBuffer.Add(new ChatMessage(ChatMessage.ChatMessageType.QUIT, DateTime.Now, Who, Reason));
        }

        public void NewKill(SenderInf Who, SenderInf ByWho, string Reason)
        {
            ChatBuffer.Add(new ChatMessage(ChatMessage.ChatMessageType.KILL, DateTime.Now, Who, ByWho, Reason));
        }

        // Get buffer for showing on screen
        public List<ChatMessage> GetScreen(int NumMessages)
        {
            /*string[] ParamSplit = { "\r\n" };
            string[] Lines = ChatBuffer.Split(ParamSplit, StringSplitOptions.RemoveEmptyEntries);
            int Start = Lines.Length - NumLines;
            if (Start < 0)
                Start = 0;
            NumLines = Lines.Length - Start;

            string[] Ret = new string[NumLines];
            for (int i = 0; i < NumLines; ++i)
            {
                Ret[i] = Lines[Start + i];
            }

            return Ret;*/
            return null;
        }
    }
}
